package controller

import (
	"hft/Http/Models/request"
	services "hft/Http/Services"
	utils "hft/Http/Utils"

	"github.com/gin-gonic/gin"
)

type SwiperCategory struct{}

func (*SwiperCategory) CreateCategory(c *gin.Context) {
	var data *request.SwiperCategory

	c.ShouldBindJSON(&data)

	err := services.SwiperCategoryServices.CreateCategory(data)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

func (*SwiperCategory) EditCategory(c *gin.Context) {
	var data *request.SwiperCategory

	c.ShouldBindJSON(&data)

	err := services.SwiperCategoryServices.EditCategory(data)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

func (*SwiperCategory) GetCategoryList(c *gin.Context) {

	var paginate request.SwiperCategoryPage

	c.ShouldBind(&paginate)

	data, err := services.SwiperCategoryServices.GetCategoryList(&paginate)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.OkWithData(data, c)
}

var SwiperCategoryController = new(SwiperCategory)
